package com.example.demo.controller;

import com.example.demo.entity.Result;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("sys/user")
public class UserController {
    @Autowired
    private UserService userService;
    /*
    * 注册
    * */
    @PostMapping("register")
    public Result editContr(MultipartFile[] file, @RequestParam Map<String,Object> paramMap, HttpServletRequest request){
        return userService.register(file,paramMap,request);
    }

    /*
     * 获取用户信息
     * */
    @GetMapping("getUserInfo")
    public Result getUserInfo(HttpServletRequest request){
        return userService.getUserInfo(request);
    }

    @PostMapping("upUserInfo")
    public Result upUserInfo(MultipartFile[] file, @RequestParam Map<String,Object> paramMap, HttpServletRequest request){
        return userService.upUserInfo(file,paramMap,request);
    }

    @GetMapping("getAllUser")
    public Result getAllUser(@RequestParam Map<String,Object> params){
        return userService.getAllUser(params);
    }

    @GetMapping("deleteUser")
    public Result deleteUser(@RequestParam Map<String,Object> params){
        return userService.deleteUser(params);
    }

    @GetMapping("getUserRole")
    public Result getUserRole(@RequestParam Map<String,Object> params){
        return userService.getUserRole(params);
    }

    @PostMapping("inserUserRole")
    public Result inserUserRole(@RequestBody Map<String,Object> paramMap, HttpServletRequest request){
        return userService.inserUserRole(paramMap,request);
    }
}
